using MediatR;
using Microsoft.AspNetCore.Mvc;
using MyServer.Todo.ClientAPI.Application.CommandHandlers.TodoGroupHandlers;
using MyServer.Todo.ClientAPI.Params.TodoGroups;

namespace MyServer.Todo.ClientAPI.Controllers
{
    [ApiController]
    [Route("api/v1")]
    public class TodoGroupsController : ControllerBase
    {
        private readonly IMediator _mediator;
        public TodoGroupsController(IMediator mediator)
        {
            _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
        }
        [HttpPost("todo-groups")]
        public async Task<IActionResult> Create([FromBody] CreateTodoGroupParam param)
        {
            var command = new CreateTodoGroupCommand
            {
                TodoGroupName = param.Name,
                UserId = "CA7E9AB5-DBC3-492B-A164-A9CCF9AB4223"
            };
            return Ok(await _mediator.Send(command));
        }
    }
}